package com.cgs.query.service.jpa

import com.cgs.query.domain.ExecutionObj
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query

interface ExecutionObjRepository : JpaRepository<ExecutionObj, String> {

    /*@Query("select qde.* from query_define qd, query_define_execution qde,project_define pd where qd.id = qde.define_id and qd.name=?1 and qde.version =pd.version " +
             "and pd.define_id = qde.define_id and pd.alias=?2 and pd.project_name=?3", nativeQuery = true)
     fun findByDefineNameAndAliasAndProjectName(name: String, tagName: String, projectName: String): ExecutionObj?*/

    @Query("select qde from QueryDefine qd, ExecutionObj qde,Project2Define pd where qd.id = qde.defineId and qd.name=?1 and qde.version = pd.version " +
            "and pd.defineId = qde.defineId and pd.alias=?2 and pd.projectName=?3")
    fun findByDefineNameAndAliasAndProjectName(name: String, tagName: String, projectName: String): ExecutionObj?

    fun findByDefineIdAndVersion(id: String, version: String): ExecutionObj

    fun findByDefineId(id: String): List<ExecutionObj>

    fun findByDefineIdIn(ids: Iterable<String>): List<ExecutionObj>
}